import { Express, Router } from 'express'
import createUserRoutes from './user'
import createSourcesRoutes from './sources'
import createUserInfoRoutes from './userInfo'
import createTalkRoutes from './talk'
import createDictTypeRoutes from './dictType'
import createDictDataRoutes from './dictData'
// 路由配置接口
interface RouteConfig {
  path: string,
  router: Router
}
const routeConfigs: RouteConfig[] = [
  {
    path: '/users',
    router: createUserRoutes()
  },
  {
    path: '/sources',
    router: createSourcesRoutes()
  },
  {
    path: '/userInfo',
    router: createUserInfoRoutes()
  },
  {
    path: '/talk',
    router: createTalkRoutes()
  },
  {
    path: '/dictType',
    router: createDictTypeRoutes()
  },
  {
    path: '/dictData',
    router: createDictDataRoutes()
  }
]
export default function (app: Express, io: any) {

  routeConfigs.forEach((routeConfig) => app.use(routeConfig.path, routeConfig.router))
  app.use(/.*/ , (req, res) => {
    res.status(404).json({ message: '资源不存在' });
  });
}

